using UnityEngine.UI;

public class BubbleWildcards : GenericDialog
{
	public Button buttonBuy1;

	public Button buttonBuy2;

	public Button buttonBuy3;

	public Text textQuantityBuy1;

	public Text textQuantityBuy2;

	public Text textQuantityBuy3;

	public Text textPriceBuy1;

	public Text textPriceBuy2;

	public Text textPriceBuy3;

	//private void OnEnable()
	//{
	//	if (Globals.appState != 0 && Globals.appState != AppState.unknown)
	//	{
	//		UpdateBuy();
	//		Economy.WildcardsChangedEvent += OnWildcardsChanged;
	//		Economy.PurchaseFinishedEvent += OnPurchaseFinished;
	//		CustomAnalytics.LogUIEvent("Menu", "Wildcards");
	//		GenericDialog.FireDialogEnabledEvent();
	//	}
	//}

	//private void OnDisable()
	//{
	//	if (Globals.appState != 0 && Globals.appState != AppState.unknown)
	//	{
	//		Economy.WildcardsChangedEvent -= OnWildcardsChanged;
	//		Economy.PurchaseFinishedEvent -= OnPurchaseFinished;
	//	}
	//}

	private void OnWildcardsChanged(int deltaWildcards)
	{
		UpdateBuy();
	}

	private void OnPurchaseFinished(bool succes)
	{
		if (succes)
		{
			UserInterface.GetInstance().CloseModalDialog();
		}
	}

	private void UpdateBuy()
	{
		//buttonBuy1.interactable = Economy.CanPurchase(IAPManager.ProductType.WildcardsPack1);
		//buttonBuy2.interactable = Economy.CanPurchase(IAPManager.ProductType.WildcardsPack2);
		//buttonBuy3.interactable = Economy.CanPurchase(IAPManager.ProductType.WildcardsPack3);
		//textQuantityBuy1.text = Economy.GetQuantityForProduct(IAPManager.ProductType.WildcardsPack1).ToString();
		//textQuantityBuy2.text = Economy.GetQuantityForProduct(IAPManager.ProductType.WildcardsPack2).ToString();
		//textQuantityBuy3.text = Economy.GetQuantityForProduct(IAPManager.ProductType.WildcardsPack3).ToString();
		//textPriceBuy1.text = Economy.GetFormattedPriceForProduct(IAPManager.ProductType.WildcardsPack1);
		//textPriceBuy2.text = Economy.GetFormattedPriceForProduct(IAPManager.ProductType.WildcardsPack2);
		//textPriceBuy3.text = Economy.GetFormattedPriceForProduct(IAPManager.ProductType.WildcardsPack3);
	}

	public void OnButtonBuy1()
	{
		Audio.PlaySoundButton();
		CustomAnalytics.LogUIEvent("Menu", "Wildcards - Buy 1");
		UserInterface.GetInstance().DoPurchase(IAPManager.ProductType.WildcardsPack1);
	}

	public void OnButtonBuy2()
	{
		Audio.PlaySoundButton();
		CustomAnalytics.LogUIEvent("Menu", "Wildcards - Buy 2");
        UserInterface.GetInstance().dialogPurchaseTips.Reset();
        AdManager.single.ShowVideo(() =>
		{
			Economy.instance.IAPSuccess(IAPManager.ProductType.WildcardsPack2);
            UserInterface.GetInstance().dialogPurchaseTips.PurchaseSuccess();
        });
        UserInterface.GetInstance().OnDisplayPurchaseTips();
    }

	public void OnButtonBuy3()
	{
		Audio.PlaySoundButton();
		CustomAnalytics.LogUIEvent("Menu", "Wildcards - Buy 3");
		UserInterface.GetInstance().DoPurchase(IAPManager.ProductType.WildcardsPack3);
	}
}
